home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jaz_clib.arc / JZSTRPOS.ASM < prev    next >
Assembly Source File  |  1989-04-09  |  924b  |  53 lines

  1.     assume cs:_text
  2. _text    segment public byte 'code'
  3.     public _jzstrpos
  4.  
  5. _jzstrpos proc near
  6.  
  7.     push bp
  8.     mov bp,sp
  9.     push si
  10.     push di
  11.  
  12.     mov si,[bp+4]            ; address of object
  13.     mov di,[bp+6]            ; address of target
  14.  
  15.     dec di
  16. next1:
  17.     inc di
  18.     mov bl,[si]            ; source index
  19.     mov bh,[di]            ; destin index
  20.     cmp bh,0            ; end of string ?
  21.     jz notfound               ; yes , exit
  22.     cmp bh,bl            ; are they equbl ?
  23.     jnz next1            ; keep looping until eos or equbl
  24.  
  25.     mov ax,di            ; get pointer to possible match
  26.     dec si
  27.     dec di
  28. next2:                    ; found a match so now check for match
  29.     inc si
  30.     inc di
  31.     mov bl,[si]
  32.     mov bh,[di]
  33.     cmp bl,0
  34.     jz found               ; go back and look for more
  35.     cmp bh,0
  36.     jz notfound
  37.     cmp bh,bl
  38.     jz next2
  39.     mov si,[bp+4]            ; point back to first char of string
  40.     jmp next1
  41.  
  42. notfound:
  43.     mov ax,0            ; return null pointer
  44. found:
  45.     pop di
  46.     pop si
  47.     mov sp,bp
  48.     pop  bp
  49.     ret
  50. _jzstrpos  endp
  51. _text    ends
  52.     end
  53.